<script type="text/javascript">
    $(document).ready(function(){
        var labels = $("form.eagleye_form").find("label[for]");
        for (var i=0; i<labels.size(); i++) {
            var label = $(labels.get(i));
            var input = $("input#" + label.attr("for"));
            var ip = label.parent().find("input[type='hidden']");
            var helpInput = ip.val();
            input.attr("title", helpInput);
            ip.remove();
            var div = $("<div/>");
            label.css({
                position:"absolute",
                "line-height":input.outerHeight() + "px",
                "margin-left":(input.parent().innerWidth() - input.innerWidth())/2 + 20,
                "margin-top":20
            });
            input.keyup({label:label}, function(event){
                var value = $(this).val();
                if (value.length > 0 ) {
                    event.data.label.hide();
                    $(this).removeClass("fieldError");
                    var errorUl = $(this).parent().find("ul.fieldErrors");
                    if (!$.isEmptyObject(errorUl.html())) {
                        errorUl.remove();
                    }
                } else {
                    event.data.label.show();
                }
            });
            input.tooltip({
                position:{
                    my:"right center",
                    at:"left-20 center",
                    of:input
                },
                items:"input[title]",
                tooltipClass:"formInputTooltip"
            });
            var errorUl = input.parent().find("ul.fieldErrors");
            if (!$.isEmptyObject(errorUl.html())) {
                input.addClass("fieldError");
            }
            if (input.val().length > 0) {
                label.hide();
            }
        }
    });
</script>